#include "http_connection.h"
#include "loop_module/loop.h"

#include <string>


int main(int argc, const char * argv[])
{
    Loop loop;
    HttpConnection conn(&loop);
    conn.InitCallbackFn([](HttpConnection * connection, int result) {

        printf("connect to server result : %d.\n", result);
        HttpRequest request;
        request.AddHeaderSign("Host", "www.baidu.com");
        connection->SendRequest(request);

    },[](HttpConnection * connection, HttpResponse * response) {

        printf("response code : %s and note : %s.\n", response->GetCode().c_str(), response->GetNote().c_str());
        printf("body size : %ld.\n", response->Body().size());
        connection->Close();

    }, [](HttpConnection * connection) {

        printf("connection:%p disconnection.\n", connection);
    });
    conn.InitHttpConnect("www.baidu.com", 443, 1);
    loop.Run();
    return 0;
}


